package com.ego.order.service;

import com.baomidou.mybatisplus.extension.service.IService;
import com.ego.common.to.order.OrderTo;
import com.ego.common.to.order.SeckillOrderTo;
import com.ego.common.vo.BaseSearchVo;
import com.ego.common.vo.PageVo;
import com.ego.common.vo.order.OrderSubmitVo;
import com.ego.order.po.Order;
import com.ego.common.to.order.OrderDetailTo;
import com.ego.common.vo.order.PayAsyncVo;
import com.ego.order.vo.PayVo;
import com.ego.order.vo.WebParamVo;

import java.util.List;
import java.util.Map;
import java.util.concurrent.ExecutionException;

/**
 * @program: ego
 * @description 订单服务层
 * @author KamTang
 * @date 2022-11-13 11:25:07
 */
public interface OrderService extends IService<Order> {

    /**
     * 提交订单
     * @param submitVo @see
     * @return @see
     * @see OrderDetailTo
     */
    OrderDetailTo submit(OrderSubmitVo submitVo);

    /**
     * 根据订单号获取订单
     * @param orderSn 订单号
     * @return @see
     * @see Order
     */
    Order get(String orderSn);

    /**
     * 关闭订单
     * @param orderTo @see
     * @see OrderTo
     */
    void close(OrderTo orderTo);

    /**
     * 根据订单号获取订单支付信息
     * @param orderSn 订单号
     * @return @see
     * @see PayVo
     */
    PayVo getPayInfo(String orderSn);

    /**
     * 分页获取前端用户订单项
     * @param param 前端参数
     * @return @see
     * @see PageVo
     */
    PageVo<Order> pageWithItem(WebParamVo param);

    /**
     * 处理支付宝支付结果
     * @param vo @see
     * @throws ExecutionException 异步异常
     * @throws InterruptedException 异步异常
     * @return 成功or失败
     * @see PayAsyncVo
     */
    boolean handlePayResult(PayAsyncVo vo) throws ExecutionException, InterruptedException;

    /**
     * 创建秒杀购物项
     * @param seckillOrder @see
     * @throws ExecutionException 异步异常
     * @throws InterruptedException 异步异常
     * @see SeckillOrderTo
     */
    void createSeckillCartItem(SeckillOrderTo seckillOrder) throws ExecutionException, InterruptedException;

    /**
     * 根据订单号获取订单详情
     * @param orderSn 订单号
     * @return @see
     * @see OrderDetailTo
     */
    OrderDetailTo detail(String orderSn);

    /**
     * 获取每个季度商品收益
     * @return QuarterlyDataVo
     */
    Map<String, List<?>> getQuarterlyEarning();

    /**
     * 获取近一周的订单数目
     * @return
     */
    Map<String, List<?>> getWeeklyData();

    /**
     * 搜索
     * @param search 基本搜索VO
     * @return 订单分页数据
     */
    PageVo<Order> search(BaseSearchVo search);
}

